import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JPanel;

/**
 * @brief Responsible for drawing the objects
 */
public final class Display extends JPanel 
{
	private static final long serialVersionUID = 4191292997598731468L;
	
	private Map map; 
	
	private int windowHeight;
	private int windowWidth;
	
	public Display()
	{
		super();
	}
	
	@Override
	public Dimension getPreferredSize()
	{
		return new Dimension(windowWidth, windowHeight);
	}
	
	@Override
	public void paintComponent(Graphics g)
	{
		super.paintComponent(g);
		
		Graphics2D g2d = (Graphics2D) g;
		
		// Draw the components with g2d
		map.drawAll(g2d);
	}
	
	public void setMap(Map map)
	{
		this.map = map;
		
		windowHeight = map.getRows()*Entity.getEntityHeight();
		windowWidth = map.getColumns()*Entity.getEntityWidth();
	}
}
